<?php


namespace app\api\controller;


use app\BaseController;
use app\Request;


class Test
{
    protected $request;

    // 容器和依赖注入
    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    /**
     * /api/test/index
     */
    public function index()
    {
        // echo "Hello World!";
        // var_dump($this->request->domain());

        $test = new \app\common\Test();
        echo $test->hello("thinkphp");

        // 无需进行实例化 直接以静态方法方式调用hello
        echo \app\facade\Test::hello('facade - thinkphp');
    }

    /**
     * 容器和依赖注入
     *
     * /api/test/hello?name=kitty
     */
    public function hello($name)
    {
        return 'Hello,' . $name . '！This action is '. $this->request->action();
    }
}